package com.study.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.study.dao.IRedisDao;
import com.study.entity.DataDictionary;
import com.study.mapper.DataDictionaryMapper;
import com.study.service.IDataDictionaryService;
import com.study.utils.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DataDictionaryServiceImpl extends ServiceImpl<DataDictionaryMapper,DataDictionary> implements IDataDictionaryService {
    @Autowired
    private IRedisDao redisDao;
    public List<DataDictionary> selectGoodsTypeList(DataDictionary dictionary) {
        String res = redisDao.get("dataDictionary_goodsType");
        if(res!=null){
            return JsonUtils.jsonToList(res,DataDictionary.class);
        }
        List<DataDictionary> list = this.selectList(new EntityWrapper<DataDictionary>(dictionary));
        redisDao.set("dataDictionary_goodsType",JsonUtils.objectToJson(list));
        return list;
    }

}
